# 努力学习
# 比肩漆时祺和周期许
# import unittest
# import requests
# from requests_01 import TpshopLoginApi
# from parameterized import parameterized
# def comm_assert(self,resp,status_code,status,msg):
#     self.assertEqual(status_code,resp.json().status_code)
#     self.assertEqual(status,resp.json().status)
#     self.assertEqual(msg,resp.json().msg)
#
# data=[
#     {
#         "resp_body_data":{"username": "18975767680", "password": "888888", "verify_code": "8888"},
#         "status_code":200,
#         "status":1,
#         "msg":"登录成功"
#
#      },
#     {
#         "resp_body_data":{"username":"1897576780", "password": "888888", "verify_code":"8888"},
#         "status_code":200,
#         "status":-1,
#         "msg":"帐号错误"
#
#      },
#     {
#         "resp_body_data":{"username": "18975767680", "password": "88888", "verify_code": "8888"},
#         "status_code":200,
#         "status":-2,
#         "msg":"密码错误"
#
#      }
#
# ]
# #定义一个读取数据的函数
# def read_data():
#     new_data=[]
#     for i in data:
#         new_data.append(tuple(i.values()))
#     return new_data
# class TestLogin(unittest.TestCase):
#     session = requests.Sesssion()
#     @classmethod
#     def setUp(self) -> None:
#         TpshopLoginApi.send_yzm(cls.session)
#
#
#     @parameterized.expand(read_data())
#     def login_ok(self,resp_body_data,status_code,status,msg):
#         # data = {"username": "18975767680", "password": "888888", "verify_code": "8888"}
#         resp=TpshopLoginApi.send_login(cls.session,resp_body_data)
#         comm_assert(resp,status_code,status,msg)
        
    # def login_phone_err(self):
    #     data = {"username": "1897576780", "password": "888888", "verify_code": "8888"}
    #     resp=session.post(cls.session,data)
    #     comm_assert(200,-1,'账号错误')
    # def login_pwd_err(self):
    #     data = {"username": "18975767680", "password": "88888", "verify_code": "8888"}
    #     resp=session.post(cls.session,data)
    #     comm_assert(200,-2,'密码错误')


import unittest
import json
import requests
from api.ihrm_login_api import SCLoginApi
from config import BASE_DIR
from parameterized import parameterized
from common.assert_tools import comm_assert
from common.read_data import read_json_data
#提取数据
# def test_data():
#     list_json=[]
#     with open(BASE_DIR+'\data\login_data.json',encoding='utf-8') as f:
#         info=json.load(f)
#         for i in info:
#             info2=tuple(i.values())
#             list_json.append(info2)
#         print(list_json)
#         return list_json
#断言数据

class SCLoginTest(unittest.TestCase):
    session=None
    @classmethod
    def setUpClass(cls) -> None:
        cls.session=requests.Session()
    direct_path=BASE_DIR+"/data/login_data.json"
    @parameterized.expand(read_json_data(direct_path))
    def test_login(self,desc,rep_data,msg,status):
        resp=SCLoginApi.login(self.session,rep_data)
        # token_data=resp.json().get('token')
        # print(token_data)
        comm_assert(self,resp,msg,status)
        print(resp.json())


if __name__ == '__main__':
    unittest.main()















